home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / CtlHandler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  7.2 KB  |  176 lines  |  [TEXT/MPS ]

  1. #ifndef __BALLOONS__
  2. #include <Balloons.h>
  3. #endif
  4.  
  5. #ifndef __CTLHANDLER__
  6. #define __CTLHANDLER__
  7.  
  8. #ifndef __TYPES__
  9. #include <Types.h>
  10. #endif
  11.  
  12. #ifndef __EVENTS__
  13. #include <Events.h>
  14. #endif
  15.  
  16. #ifndef __WINDOWS__
  17. #include <Windows.h>
  18. #endif
  19.  
  20. #define kScrollEvent    0x8000
  21.  
  22.  
  23.  
  24. short    IsCtlEvent(WindowPtr window, EventRecord *event, ControlHandle *ctl, short *action);
  25.     /*
  26.     ** INPUT:    window        Window that owns the controls that the event is to be applied to
  27.     **            event        The event to apply to the controls
  28.     ** OUTPUT:    ctl            The control that ate the event.  If you don't care, pass in nil
  29.     **            action        The action of the control that ate the event.  If you don't
  30.     **                        care, pass in nil.  Note that the action varies with the control
  31.     **                        type.
  32.     ** RESULT:    short        The control ID of the control that ate the event.  If no control
  33.     **                        ate the event, then 0 is returned.  If a document scrollbar ate
  34.     **                        the event, then kScrollEvent is returned.
  35.     **
  36.     ** See the file “=Using CtlHandler.c” for a complete description of this function.
  37.     */
  38.  
  39.  
  40.  
  41. short    CNum2Ctl(WindowPtr window, short ctlNum, ControlHandle *ctl);
  42.     /*
  43.     ** INPUT:    window        Window that owns the control list to be scanned.
  44.     **            ctlNum        ID of the control to search for.
  45.     ** OUTPUT:    ctl            If a control is found with the correct ID, it is returned here.
  46.     ** RESULT:    short        ID of found control (archaic)
  47.     **
  48.     ** AppsToGo extends the control record.  This means that, among other things, controls
  49.     ** can have a fixed control ID.  If a control has a style, and the ctlID field if the 
  50.     ** style is non-zero, then that control has a fixed control ID.  Due to this, CNum2Ctl
  51.     ** first scans all of the controls for a control with a style that has the designated
  52.     ** ctlID.  If one is found, then that's the control returned.  If none is found, then
  53.     ** the behavior for this function is as before (for the purpose of backwards-compatibility).
  54.     **
  55.     ** The way that this function used to work is:
  56.     ** 
  57.     **        It simply walks the window's control list counting down until it has reached
  58.     **        the right control number.  It also returns the number of controls traversed.
  59.     **        While often this will be the same as the control number passed in, if the
  60.     **        number passed in is greater than the number of controls in the list, then
  61.     **        the number returned is the number of controls in the list.
  62.     */
  63.  
  64.  
  65.  
  66. short    Ctl2CNum(ControlHandle ctl);
  67.     /*
  68.     ** INPUT:    ctl        Control handle to convert to an ID.
  69.     ** RESULT:    short    The ID of the control passed in.
  70.     **
  71.     ** This function converts a control handle to a control number.  This allows you to convert
  72.     ** what is normally a runtime variable into something that can be equated to a constant,
  73.     ** thus allowing you to code your control handling into case statements.  This function
  74.     ** does the opposite of CNum2Ctl. */
  75.  
  76.  
  77.  
  78. void    DoCtlActivate(WindowPtr window);
  79.     /*
  80.     ** INPUT:    window        Window whose TextEdit or List control is to be reactivated
  81.     **
  82.     ** This reactivates the TextEdit or List control that was active for a particular window.
  83.     ** When a window is moved from the front, the controls are supposed to become inactive.
  84.     ** This is handled, but the control that was last active for a window is remembered.
  85.     ** When the window is brought to the front, that particular control can be reactivated
  86.     ** by calling DoCtlActivate(). */
  87.  
  88.  
  89.  
  90. void    GetCheckBoxValues(WindowPtr window, Boolean checkBoxVal[]);
  91.     /*
  92.     ** INPUT:    window            Window whose control list is to be scanned for
  93.     **                            checkBox controls.
  94.     ** OUTPUT:    checkBoxVal        An array that is to receive the value of the checkBox
  95.     **                            controls in the windowList.  It is the caller's
  96.     **                            responsibility to guarantee that the array is large enough.
  97.     **                            This function will use one array element for every
  98.     **                            checkBox control found in the control list of the window.
  99.     */
  100.  
  101.  
  102.  
  103. short    GetRadioButtonChoice(WindowPtr window, short famNum);
  104.     /*
  105.     ** INPUT:    window        Window containing the family of radio buttons.
  106.     **            famNum        The family number of the radio buttons.
  107.     ** RESULT:    short        Which radio button in the family that is selected.
  108.     **
  109.     ** Given a particular family number, return which radio button is the currently selected
  110.     ** button.  If the requested family isn't found, or there are no selected radio buttons
  111.     ** in the family, -1 is returned.  If the family is found, the control number of the the
  112.     ** selected radio button minus the control number of the first in the family is returned.
  113.     ** ••• The first in the family is the control with the smallest ID. •••
  114.     ** This means that for most situations, you will simply get an integer from 0-N for the
  115.     ** radio button selection, as in most cases, the radio button ID's will be sequential in
  116.     ** the control list. */
  117.  
  118.  
  119.  
  120. ControlHandle    CDataNext(WindowPtr window, ControlHandle ctl);
  121.     /*
  122.     ** INPUT:    window            Window containing control list to scan.
  123.     **            ctl                Control to start search from (nil for beginning of list)
  124.     ** RESULT:    ControlHandle    Next data control in list (nil indicates no more in list)
  125.     **
  126.     ** When a set of controls defined with the AppsToGo editor is added to a window, an
  127.     ** additional Data control is also added.  The purpose of the Data control is to keep
  128.     ** track of which controls were added as a set of controls.  (The Data control "groups"
  129.     ** the set of controls.)  CDataNext allows you to get the next data control out of the
  130.     ** window's control list.  (Normally you won't need this function.) */
  131.  
  132.  
  133.  
  134. Boolean    ControlBalloonHelp(WindowPtr window, short modifiers, Point mouseLoc);
  135.     /*
  136.     ** INPUT:    window            Window containing controls that may have balloon help info.
  137.     **            modifiers        This is in case the application is using fast balloons.
  138.     **            mouseLoc        Current mouse location, in global coordinates.
  139.     ** RESULT:    Boolean            True if a balloon was displayed.
  140.     **
  141.     ** This function is actually in Help.c, but it is specifically for managing
  142.     ** balloon help for controls.  IsCtlEvent calls it, although you can call it
  143.     ** yourself, if you want.  (There shouldn't be any reason for an application
  144.     ** to call this directly. */
  145.  
  146.  
  147.  
  148. ControlHandle    ControlBalloonMessage(WindowPtr window, Point mouseLoc, HMMessageRecord *msg,
  149.                                       Rect *msgRct, short *pos, short *hrctID, short *itemID);
  150.     /*
  151.     ** INPUT:    window            Window containing controls that may have balloon help info.
  152.     **            mouseLoc
  153.     ** OUTPUT:    msg                The Balloon Help message record.  This is what should be
  154.     **                            displayed in the balloon.
  155.     **            msgRct            The rect of the control the help message relates to.
  156.     **            pos                The balloon position.
  157.     **            hrctID            The 'hrct' resource ID.
  158.     **            itemID            The 'hrct' resource item ID.
  159.     ** RESULT:    ControlHandle    The control the help is for. */
  160.  
  161.  
  162.  
  163. PicHandle        BalloonText2PICT(WindowPtr window, HMMessageRecord *msg);
  164.     /*
  165.     ** INPUT:    window            Window that the balloon help is for.
  166.     **            msg                The Balloon Help message record.  (May or may not be a text record.)
  167.     ** RESULT:    PicHandle        If the Balloon Help record is text, then a PicHandle is created
  168.     **                            that contains the text.
  169.     ** This function converts a Balloon Help text message into a PicHandle.  This is because
  170.     ** Balloon Help only automatically works for text strings less than 255 characters.
  171.     ** Longer balloons need to be done with the PICT resource type.  This function converts
  172.     ** text messages into a PICT so that long text can be used without having to create
  173.     ** a PICT. */
  174.  
  175. #endif
  176.